package com.base.self.controller;

import com.base.log.LoginAn;
import com.base.result.ResponseResult;
import com.base.self.dto.selfAddress.SelfAddressWebListDTO;
import com.base.self.dto.selfAddress.SelfAddressWebUpdateDTO;
import com.base.self.service.ISelfAddressService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 收货地址 前端控制器
 * </p>
 *
 * @author XiFYuW
 * @since 2020-11-17
 */
@RestController
@RequestMapping("/admin/selfAddress")
public class SelfAddressController {
    private final ISelfAddressService iSelfAddressService;

    public SelfAddressController(ISelfAddressService iSelfAddressService) {
        this.iSelfAddressService = iSelfAddressService;
    }

    @GetMapping(value = "/selfAddressIndex")
    @LoginAn
    public ModelAndView selfAddressIndex() {
        return new ModelAndView("self/index_self_address");
    }

    @PostMapping(value = "/selfAddressWebList")
    @LoginAn(isRe = true)
    public ResponseResult selfAddressWebList(@Validated final SelfAddressWebListDTO selfAddressWebListDTO) {
        return iSelfAddressService.selfAddressWebList(selfAddressWebListDTO);
    }

    @PostMapping(value = "/selfAddressWebUpdate")
    @LoginAn(isRe = true)
    public ResponseResult selfAddressWebUpdate(@Validated final SelfAddressWebUpdateDTO selfAddressWebUpdateDTO) {
        return iSelfAddressService.selfAddressWebUpdate(selfAddressWebUpdateDTO);
    }
}

